<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" type="text/css">
</head>
<body>
    <div id='container' style="width: 600px; height: 600px;"></div>
    <div>
        <input type="button" value="开始绘画" onclick="beginDraw()">
        <input type="button" value="清除">

    </div>

    <script src="https://webapi.amap.com/maps?v=1.4.15&key=ae82f1373cedbca373e78dba0188b6b9&plugin=AMap.MouseTool"></script>
    <script>
        // 参考例子
        // https://lbs.amap.com/demo/javascript-api/example/mouse-operate-map/mouse-draw-overlayers

        var map = new AMap.Map('container',{
            zoom:14
        });
        var mouseTool = new AMap.MouseTool(map);
        //监听draw事件可获取画好的覆盖物
        var overlays = [];
        mouseTool.on('draw',function(e){
            overlays.push(e.obj);
            console.log(e);
            console.log(e.obj.getPath())
        }) 
        function beginDraw(){
            mouseTool.polygon({
              fillColor:'#00b0ff',
              strokeColor:'#80d8ff'
              //同Polygon的Option设置
            });
        }

    </script>
</body>
</html>